# coding=utf-8

from datetime import date

class DottableDict(dict):
    def __init__(self, *args, **kwargs):
        dict.__init__(self, *args, **kwargs)
        self.__dict__ = self

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))

def getdata(data):
    if data is None:
        return ''
    return data

def get_dictdata(key, dictdata):
    if key in dictdata and dictdata[key]:
        return dictdata[key]
    return ''
